package cn.jiyun.guige.product.controller;

import cn.jiyun.common.vo.CommonResult;
import cn.jiyun.guige.product.service.ProductGuigeService;
import cn.jiyun.model.ProductGuige;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/guige")
public class GuigeController {
    @Autowired
    private ProductGuigeService productGuigeService;
    @PostMapping("/findAll")
    public CommonResult findAll(Integer pageNum, Integer pageSize, @RequestBody ProductGuige productGuige){
        Page<ProductGuige> all = productGuigeService.findAll(pageNum, pageSize, productGuige);
        return  CommonResult.success(all);
    }
    @PostMapping("/findAdd")
    public  CommonResult findAdd(@RequestBody ProductGuige productGuige){
        CommonResult commonResult =  productGuigeService.findAdd(productGuige);
        return commonResult;
    }
    @PostMapping("/findUpdate")
    public  CommonResult findUpdate(@RequestBody ProductGuige productGuige){
        CommonResult commonResult =  productGuigeService.findUpdate(productGuige);
        return commonResult;
    }
    @DeleteMapping("/deletebyid")
    public  CommonResult deletebyid( Integer id){
        CommonResult commonResult =  productGuigeService.deletebyid(id);
        return commonResult;
    }
    @DeleteMapping("/deleteIds")
    public  CommonResult deleteIds(@RequestParam("ids") Integer[] ids){
        CommonResult commonResult =  productGuigeService.deleteIds(ids);
        return commonResult;
    }
    @GetMapping("/findtotal")
    public List<ProductGuige> findtotal(){
        List<ProductGuige> list = productGuigeService.findtotal();
        return list;
    }
    @GetMapping("/findGuigefeign/{id}")
    public ProductGuige findGuigefeign(@PathVariable Integer id){
        return productGuigeService.getOne(new LambdaQueryWrapper<ProductGuige>().eq(ProductGuige::getId,id));
    }
    @GetMapping("/findBeanByid/{id}")
    public List<ProductGuige> findBeanByid(@PathVariable Integer id){
        return productGuigeService.findBeanByid(id);
    }
    @GetMapping("/findGuigefeign1")
    public List<ProductGuige> findGuigefeign1(){
        return productGuigeService.list();
    }

}
